package net.lab1024.sa.admin.module.business.erp.sao.controller;

import net.lab1024.sa.admin.module.business.erp.sao.domain.form.SiordaAddForm;
import net.lab1024.sa.admin.module.business.erp.sao.domain.form.SiordaQueryForm;
import net.lab1024.sa.admin.module.business.erp.sao.domain.form.SiordaUpdateForm;
import net.lab1024.sa.admin.module.business.erp.sao.domain.vo.SiordaVO;
import net.lab1024.sa.admin.module.business.erp.sao.service.SiordaService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import cn.dev33.satoken.annotation.SaCheckPermission;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 销售发货单行 Controller
 *
 * @Author AKITA
 * @Date 2025-08-27 14:32:56
 * @Copyright AKITA
 */

@RestController
@Tag(name = "销售发货单行")
public class SiordaController {

    @Resource
    private SiordaService siordaService;

    @Operation(summary = "分页查询 @author AKITA")
    @PostMapping("/siorda/queryPage")
    @SaCheckPermission("siorda:query")
    public ResponseDTO<PageResult<SiordaVO>> queryPage(@RequestBody @Valid SiordaQueryForm queryForm) {
        return ResponseDTO.ok(siordaService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author AKITA")
    @PostMapping("/siorda/add")
    @SaCheckPermission("siorda:add")
    public ResponseDTO<String> add(@RequestBody @Valid SiordaAddForm addForm) {
        return siordaService.add(addForm);
    }

    @Operation(summary = "更新 @author AKITA")
    @PostMapping("/siorda/update")
    @SaCheckPermission("siorda:update")
    public ResponseDTO<String> update(@RequestBody @Valid SiordaUpdateForm updateForm) {
        return siordaService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author AKITA")
    @PostMapping("/siorda/batchDelete")
    @SaCheckPermission("siorda:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return siordaService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author AKITA")
    @GetMapping("/siorda/delete/{id}")
    @SaCheckPermission("siorda:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Long id) {
        return siordaService.delete(id);
    }
}
